const mongoose = require('mongoose');
const { Article } = require('../../model/article')
const { Classify } = require('../../model/classify')
module.exports = async (req, res) => {
    try {
        var data = await Classify.find()
    } catch (err) {
        return res.send({
            data: null,
            meta: {
                status: 400,
                msg: '请求失败'
            }
        })
    }
    for (let i in data) {
        var value = await Article.find({ class: data[i]._id }).count()
        var { _id, name } = data[i]
        data[i] = {
            name, value
        }

    }
    res.send({
        data,
        meta: {
            status: 200,
            msg: '请求成功'
        }
    })
}